using System;

namespace Prometheus.Binding.Validation.Rules.Simple
{
    public class proIsUnsignedIntegerRule : proValidationRuleBase
    {
        public proIsUnsignedIntegerRule()
        {   
            ErrorText = "Value must be positive and integer";
        }

        public override void Validate(object value, object dataContext)
        {
            if(value==null)ThrowInvalid();
            UInt32 result = 0;
            if(value != null && !UInt32.TryParse(value.ToString(), out result))ThrowInvalid();
            if(result<=0)ThrowInvalid();
        }
    }
}